package com.antaohua.platfrom.framework.web.converter;

import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4;
import com.antaohua.platfrom.framework.web.utils.JsonResult;

import org.springframework.http.HttpInputMessage;
import org.springframework.http.HttpOutputMessage;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.http.converter.HttpMessageNotWritableException;

import java.io.IOException;
import java.lang.reflect.Type;


public class JsonHttpMessageConverter extends FastJsonHttpMessageConverter4 {

	@Override
	protected void writeInternal(Object obj, Type type, HttpOutputMessage outputMessage)throws IOException, HttpMessageNotWritableException {
		obj = new JsonResult(JsonResult.STATUS_SUCCESS,obj);
		super.writeInternal(obj, type, outputMessage);
		
	}

	@Override
	public Object read(Type type, Class<?> contextClass, HttpInputMessage inputMessage)
			throws IOException, HttpMessageNotReadableException {
		return super.read(type, contextClass, inputMessage);
	}

	@Override
	protected Object readInternal(Class<? extends Object> clazz, HttpInputMessage inputMessage)
			throws IOException, HttpMessageNotReadableException {
		return super.readInternal(clazz, inputMessage);
	}
	
	

	


}
